using Pdf2epub.BusinessLogic.Extractors;
using Pdf2epub.Interfaces;
using System.Globalization;
using System.IO;

namespace Pdf2epub.BusinessLogic
{
    internal class FontAnalyzerFactory
    {
        public static IFontAnalyzer GetAnalyzer(IProjectContext projectContext)
        {
            string extension = Path.GetExtension(projectContext.ProjectConfiguration.PdfPath);
            if (string.IsNullOrEmpty(extension))
                return null;

            extension = extension.ToLower(CultureInfo.InvariantCulture).Trim('.');

            switch (extension)
            {
                case "pdf":
                    return new PdfFontAnalyzer(projectContext);
                case "zip":
                    return new GalileoOpenBookFontAnalyzer(projectContext);
            }
            return null;
        }
    }
}